package com.rxyb.rabbitmq.rabbitmq.config;

import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.UUID;

/**
 * 队列消息生产者
 *
 * @author lcf
 * @date 2020-06-10-10:09
 */
@Component
public class Producer {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
     * 生产消息
     *
     * @param message
     */
    public void directExchangeRequest(String message) {
        message="测试";
        String msgId = UUID.randomUUID().toString();
        CorrelationData data=new CorrelationData(msgId);
        rabbitTemplate.convertAndSend("My-Direct-Exchange", "requestTest.aa",message,data);
    }

}
